unit uModeloCadastros;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls;

type
  TFrmModeloCadastros = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    DBGrid1: TDBGrid;
    StatusBar1: TStatusBar;
    GroupBox1: TGroupBox;
    cbFiltro: TComboBox;
    GroupBox2: TGroupBox;
    EdtValor: TEdit;
    TabSheet2: TTabSheet;
    Bevel1: TBevel;
    BtnNovo: TBitBtn;
    BtnAlterar: TBitBtn;
    BtnCancelar: TBitBtn;
    BtnExcluir: TBitBtn;
    BtnSalvar: TBitBtn;
    BtnSair: TBitBtn;
    procedure FormShow(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure BtnNovoClick(Sender: TObject);
    procedure BtnAlterarClick(Sender: TObject);
    procedure BtnCancelarClick(Sender: TObject);
    procedure BtnSalvarClick(Sender: TObject);
    procedure BtnSairClick(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private

  public
    { Public declarations }
  end;

implementation

{$R *.dfm}

procedure TFrmModeloCadastros.BtnAlterarClick(Sender: TObject);
begin
 BtnNovo.Enabled     := False;
 BtnAlterar.Enabled  := False;
 BtnCancelar.Enabled := True;
 BtnExcluir.Enabled  := False;
 BtnSalvar.Enabled   := True;
 BtnSair.Enabled     := False;
end;

procedure TFrmModeloCadastros.BtnCancelarClick(Sender: TObject);
begin
 BtnNovo.Enabled     := True;
 BtnAlterar.Enabled  := True;
 BtnCancelar.Enabled := False;
 BtnExcluir.Enabled  := True;
 BtnSalvar.Enabled   := False;
 BtnSair.Enabled     := True;
end;

procedure TFrmModeloCadastros.BtnNovoClick(Sender: TObject);
begin
 BtnNovo.Enabled     := False;
 BtnAlterar.Enabled  := False;
 BtnCancelar.Enabled := True;
 BtnExcluir.Enabled  := False;
 BtnSalvar.Enabled   := True;
 BtnSair.Enabled     := False;
end;

procedure TFrmModeloCadastros.BtnSairClick(Sender: TObject);
begin
 close;
end;

procedure TFrmModeloCadastros.BtnSalvarClick(Sender: TObject);
begin
 BtnNovo.Enabled     := True;
 BtnAlterar.Enabled  := True;
 BtnCancelar.Enabled := False;
 BtnExcluir.Enabled  := True;
 BtnSalvar.Enabled   := False;
 BtnSair.Enabled     := True;
end;

procedure TFrmModeloCadastros.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if key = vk_Escape then
  Close;
end;

procedure TFrmModeloCadastros.FormKeyPress(Sender: TObject; var Key: Char);
begin
 if (Key=#13) then Begin
  Key:=#0;
  Perform(Wm_NextDlgCtl,0,0);
 end;
end;

procedure TFrmModeloCadastros.FormShow(Sender: TObject);
begin
 PageControl1.ActivePageIndex := 0;
end;

end.
